package top.lucas9.wechat.push.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import top.lucas9.wechat.push.entity.User;
import top.lucas9.wechat.push.entity.Weather;
import top.lucas9.wechat.push.service.WeatherService;
import top.lucas9.wechat.push.util.WeatherUtil;

/**
 * @author lucas9
 * @date 2022/11/29 15:06
 */
@Service
public class WeatherServiceImpl implements WeatherService {
    public Weather getWeather(User user) {
        Assert.isTrue(user.hasLocation(), "未获取到用户地理位置信息,请检查后重试");
        return WeatherUtil.getWeather(user.getLatitude(), user.getLongitude());
    }

    public Weather getWeather(String latitude, String longitude) {
        return WeatherUtil.getWeather(latitude, longitude);
    }
}
